app.controller("home", ["$scope", "$interval", "$rootScope", "$location", "$state", "$http", function($scope, $interval, $rootScope, $location, $state, $http) {
	$rootScope.page.footer = 'home';
	$rootScope.page.showfooter = true;
	scrollTo(0, 0);
	BackTop()
	$rootScope.record()
	//微信分享
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Share/share_s',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			url: $location.absUrl()
		}
	}).success(function(result) {
		var appid = result.appId;
		var timestamp = result.timestamp;
		var nonceStr = result.nonceStr;
		var signature = result.signature;
		if(localStorage.getItem("user_ID")) {
			var urlAfter = "http://app.tl178.cn/#/home/?fff=" + localStorage.getItem("user_ID") + "";
		} else {
			var urlAfter = $location.absUrl()
		}
		var title = "中国唯一宜居地产互联网平台"
		var imgUrl = "http://web.tl178.cn/Public/admin/slideshow/15032811371503281137.jpg"
		var desc = "天乐成立于2014年，是国内首个宜居地产互联网平台，通过自然和贴心的交互方式满足用户在热点线路上的房产投资需求，大自然是您最好的家，打开生命新维度。"
		wx.config({
			debug: false, //开启调试模式,调用的所有api的返回值会在客户端alert出来
			appId: appid, // 必填，公众号的唯一标识
			timestamp: timestamp, // 必填，生成签名的时间戳
			nonceStr: nonceStr, // 必填，生成签名的随机串
			signature: signature, // 必填，签名
			jsApiList: [
				'onMenuShareTimeline', //分享到朋友圈
				'onMenuShareAppMessage', //分享给朋友
				'onMenuShareQQ', //分享给QQ好友
				'showOptionMenu'
			]
		});
		wx.ready(function() {
			wx.showOptionMenu();
			wx.onMenuShareTimeline({
				title: title,
				desc: desc, // 分享标题							
				link: urlAfter, // 分享链接
				imgUrl: imgUrl, // 分享图片
				success: function() {
					$rootScope.shareSuccess(2)
				},
				cancel: function() {
					// 用户取消分享后执行的回调函数
				}
			});

			wx.onMenuShareAppMessage({
				title: title, // 分享标题
				desc: desc, // 分享描述
				link: urlAfter, // 分享链接
				imgUrl: imgUrl, // 分享图片
				type: '', // 分享类型,music、video或link，不填默认为link
				dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
				success: function() {
					$rootScope.shareSuccess(1)
					// 用户确认分享后执行的回调函数
				},
				cancel: function() {
					// 用户取消分享后执行的回调函数
				}
			});

			wx.onMenuShareQQ({
				title: title, // 分享标题
				desc: desc, // 分享描述
				link: urlAfter, // 分享链接
				imgUrl: imgUrl, // 分享图标
				success: function(res) {
					$rootScope.shareSuccess(3)
					// 用户确认分享后执行的回调函数
				},
				cancel: function(res) {
					// 用户取消分享后执行的回调函数
				}
			});
		});
		wx.error(function(res) {
			console.log(res)
		});
	})
	if($location.search().id) {
		var openid = $location.search().id
		$http({
			type: "post",
			async: true,
			url: "" + $rootScope.Location + "Login/get_user?id=" + openid,
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		}).success(function(data) {
			localStorage.setItem("user_ID", data["list"]["user_Id"])
			localStorage.setItem("token", data["list"]["token"])
		})
	} else {

	}

	//获取user_Id
	if(localStorage.getItem("user_ID")) {
		var userID = localStorage.getItem("user_ID")
	}
	var mySwiper = new Swiper('.banner', {
		autoplay: 2000,
		//		loop:true,
		//		loopAdditionalSlides : 1,
		pagination: '.swiper-pagination',
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		//pagination : '#swiper-pagination1',
		autoplayDisableOnInteraction: false,
	})
	var mySwiper = new Swiper('.Recommend_banner', {
		autoplay: 2500,
		//loop: true,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		direction: 'vertical',
		//pagination : '#swiper-pagination1',
		autoplayDisableOnInteraction: false,
	})
	var mySwiper = new Swiper('.join_People', {
		autoplay: 2500,
		//		loop: true,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		//pagination : '#swiper-pagination1',
		autoplayDisableOnInteraction: false,
	})
	//首页单个图片广告
	//	$http({
	//			type: "post",
	//			async: true,
	//			url: "" + $rootScope.Location + "Data/ertising",
	//			headers: {
	//				'Content-Type': 'application/x-www-form-urlencoded'
	//			},
	//			data: {
	//				user_Id: localStorage.getItem("user_ID"),
	//				token: localStorage.getItem("token"),
	//			}
	//	}).success(function(data) {
	//			$scope.select_logo = data["list"]
	//		})
	//请求首页轮播图
	//	$http({
	//		type: "post",
	//		async: true,
	//		url: "" + $rootScope.Location + "Picture/slideshow",
	//		headers: {
	//			'Content-Type': 'application/x-www-form-urlencoded'
	//		},	
	//	}).success(function(data){
	//		console.log(data)
	//		$scope.bannerImg = data
	//		$scope.toInfo = function(href) {
	//			window.location.href = href
	//		}
	//	})
	$.ajax({
		type: "post",
		url: "" + $rootScope.Location + "Picture/slideshow",
		async: true,
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			href: $location.absUrl()
		},
		success: function(data) {
			var data = JSON.parse(data)
			$scope.bannerImg = data
			$scope.toInfo = function(href) {
				window.location.href = href
			}
		}
	});
	//八个推荐
	$http({
		type: "post",
		async: true,
		url: "" + $rootScope.Location + "Picture/icon",
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
//		console.log(data)
		$scope.icon_list = data
		$scope.goserList = function(id, name, href, priority) {
			if(priority == 1) {
				window.location.href = href
			}
			if(id == 1 && priority == 0) {
				$state.go("main.serviceList", {
					id: id,
					name: name
				})
			}
			if(id == 2 && priority == 0) {
				$state.go("main.serviceList", {
					id: id,
					name: name
				})
			}
			if(id == 3 && priority == 0) {
				$state.go("main.serviceList", {
					id: id,
					name: name
				})
			}
			if(id == 4 && priority == 0) {
				$state.go("main.serviceList", {
					id: id,
					name: name
				})
			}
			if(id == 5 && priority == 0) {
				$state.go("main.serviceList", {
					name: name,
					id: id
				})
			}
			if(id == 6 && priority == 0) {
				$state.go("main.serviceList", {
					name: name,
					id: id
				})
			}
			if(id == 7 && priority == 0) {
				$state.go("main.serviceList", {
					name: name,
					id: id
				})
			}
			if(id == 8 && priority == 0) {
				$state.go("main.serviceList", {
					name: name,
					id: id
				})
			}
		}
	})
	//天乐推荐两个专题
	$http({
		type: "post",
		async: true,
		url: "" + $rootScope.Location + "Picture/recommend",
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
		//					console.log(data)
		$scope.recommend = data
		$scope.toHref = function(type, href) { //2是跳外链，1是跳内部 
			if(type == 2) {
				window.location.href = href
			} else {

			}
		}
	})
	//天乐推荐滚动内容	
	$http({
		type: "post",
		async: true,
		url: "" + $rootScope.Location + "Picture/roll",
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
		//		console.log(data)
		$scope.roll = data
		$scope.toHeadnews = function(Id) {
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'Picture/headline',
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				data: {
					Id: Id,
				}
			}).success(function(data) {
				if(data["list"]["priority"] == 1) {
					$state.go("main.headLineNews", {
						Id: Id
					})
				}
				if(data["list"]["priority"] == 2) {
					window.location.href = data["list"]["href"]
				}
			})
		}
	})
	//路线参团滚动信息
	$http({
		type: "post",
		async: true,
		url: "" + $rootScope.Location + "House/look",
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
		$scope.tuanNum = data["num"]
		$scope.name = data["list"]
	})
	//请求推荐项目内容
	$http({
		type: "post",
		async: true,
		url: "" + $rootScope.Location + "House/houses",
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
//		console.log(data)
		$scope.data = data
		$scope.toprojectInfo = function(Id, type) {
			if(type == 2) {
				$state.go("main.newprojectInfo", {
					Id: Id
				})
			} else {
				$state.go("main.projectInfo", {
					Id: Id
				})
			}
		}
	})
	//首页线路列表

	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'House/roadlist',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
//		console.log(data)
		$scope.route_list = data["list"]
		$scope.today = new Date().getTime() / 1000
		showtimes()

		function showtimes() {
			setTimeout(function() {
				$scope.today = new Date().getTime() / 1000
				var times = document.querySelectorAll(".times")
				for(var i = 0; i < times.length; i++) {
					var a = times[i].getAttribute("data-info")
					var d = parseInt(a / (60 * 60) / 24) <= 9 ? "0" + parseInt(a / (60 * 60) / 24) : parseInt(a / (60 * 60) / 24);
					var h = parseInt(a / 3600 % 24) <= 9 ? "0" + parseInt(a / 3600 % 24) : parseInt(a / 3600 % 24);
					var m = parseInt(a / 24 % 60) <= 9 ? "0" + parseInt(a / 24 % 60) : parseInt(a / 24 % 60)
					var s = parseInt(a % 60) <= 9 ? "0" + parseInt(a % 60) : parseInt(a % 60)
					if(s < 0) {
						s = 60 + s;
						m = m - 1;
					}
					if(m < 0) {
						m = 60 + m;
						h = h - 1;
					}
					if(h < 0) {
						h = 24 + h;
						d = d - 1
					}
					times[i].innerHTML = d + "天" + " " + h + "时" + " " + m + "分" + " " + s + "秒"
				}
			}, 1)
		}
		var timeout = $interval(function() {
			showtimes()
		}, 1000)
		$scope.$on('$destroy', function() {
			$interval.cancel(timeout);
		})
		//		}	
		$scope.toroutInfo = function(id) {
			$state.go("main.routeInfo", {
				Id: id
			})
		}
	})

	$scope.toproject_Info = function() {
		$state.go("main.projectInfo")
	}
	$scope.toInfo = function() {
		$state.go("main.routeInfo")
	}
	$scope.choose_house = function() { //选房按钮点击
		clearInterval($rootScope.waitTime)
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Submit/click_house',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: userID
			}
		}).success(function(data) {
//			console.log(data)
			$scope.house = data["list"]["house"]
			if(data["list"]["attestation"] == 1) { //注册用户
				$scope.page.Loginshow = true
				setTimeout(function() {
					for(var k = 0; k < $(".layout2 ul li").length; k++) {
						$(".layout2 ul li").eq(k).click(function() {
							var index = $(this).index()
							$(".layout2 ul li").eq(index).attr("class", "active").siblings().removeClass("active")
						})
					}
				}, 100)
				$(".btn2").click(function() {
					for(var j = 0; j < $(".layout2 ul li").length; j++) {
						if($(".layout2 ul li").eq(j).attr("class") == "active") {
							var house = $(".layout2 ul li").eq(j).html()
							var house_ID = $(".layout2 ul li").eq(j).attr("data-info")
						}
					}
					$http({
						method: 'post',
						url: '' + $rootScope.Location + 'Submit/sub_house',
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						data: {
							user_Id: localStorage.getItem("user_ID"),
							token: localStorage.getItem("token"),
							type: 1,
							house_Id: house_ID
						}
					}).success(function(data) {
						if(data["status"] == 1) {
							$(".addressdialog").show();
							$(".addressdialog").html(data["message"]);
							$(".addressdialog").fadeOut(1200);
							setTimeout(function() {
								window.location.reload()
							}, 1000)
						} else {
							$(".addressdialog").show();
							$(".addressdialog").html(data["message"]);
							$(".addressdialog").fadeOut(1200);
						}
					})
				})
			} else { //非注册用户
				setTimeout(function() {
					for(var k = 0; k < $(".layout1 ul li").length; k++) {
						$(".layout1 ul li").eq(k).click(function() {
							var index = $(this).index()
							$(".layout1 ul li").eq(index).attr("class", "active").siblings().removeClass("active")
						})
					}
				}, 100)
				$(".btn").click(function() {
					if(!$('.tel').val()) {
						$(".addressdialog").show();
						$(".addressdialog").html("手机号不能为空");
						$(".addressdialog").fadeOut(1200);
					} else {
						var reg = new RegExp(/^1[34578]\d{9}$/);
						if(!reg.test($('.tel').val()) || $('.tel').val().length != 11) {
							$(".addressdialog").show();
							$(".addressdialog").html("请输入正确的手机号");
							$(".addressdialog").fadeOut(1200);
						} else {
							$http({
								method: 'post',
								url: '' + $rootScope.Location + 'Login/send',
								data: {
									mobile: $('.tel').val(),
									type: 3
								},
								headers: {
									'Content-Type': 'application/x-www-form-urlencoded'
								},
							}).success(function(data) {
								$(".addressdialog").show();
								$(".addressdialog").html("验证码发送成功");
								$(".addressdialog").fadeOut(1200);
								var wait = 60;
								$(".btn").attr("disabled", true);
								$(".btn").css({
									"color": "#B3B3B3"
								})
								$rootScope.waitTime = setInterval(function() {
									$(".btn").html("重新发送" + "(" + wait + ")")
									wait--
									if(wait < 0) {
										$(".btn").html("获取验证码")
										$(".btn").attr("disabled", false);
										$(".btn").css({
											"color": "#000"
										})
										clearInterval($rootScope.waitTime)
									}
								}, 1000)
							})
						}
					}
				})

				$(".btn1").click(function() {
					var name = $(".name").val();
					for(var j = 0; j < $(".layout1 ul li").length; j++) {
						if($(".layout1 ul li").eq(j).attr("class") == "active") {
							var house = $(".layout1 ul li").eq(j).html()
							var house_Id = $(".layout1 ul li").eq(j).attr("data-info")
						}
					}
					if(name == "") {
						$(".addressdialog").show();
						$(".addressdialog").html("姓名不能为空");
						$(".addressdialog").fadeOut(1200);
						return false
					} else {
						var phone = $('.tel').val();
						var reg = new RegExp(/^1[34578]\d{9}$/);
						if(!reg.test(phone) || phone.length != 11) {
							$(".addressdialog").show();
							$(".addressdialog").html("请输入正确的手机号");
							$(".addressdialog").fadeOut(1200);
							return false;
						} else {
							if(!$(".code").val()) {
								$(".addressdialog").show();
								$(".addressdialog").html("验证码不能为空");
								$(".addressdialog").fadeOut(1200);
							} else {
								if(!house) {
									$(".addressdialog").show();
									$(".addressdialog").html("请选择户型");
									$(".addressdialog").fadeOut(1200);
									return false;
								} else {
									$http({
										method: 'post',
										url: '' + $rootScope.Location + 'Submit/sub_house',
										headers: {
											'Content-Type': 'application/x-www-form-urlencoded'
										},
										data: {
											username: name,
											mobile: phone,
											code: $(".code").val(),
											type: 2,
											house_Id: house_Id
										}
									}).success(function(data) {
										if(data["status"] == 1) {
											$(".addressdialog").show();
											$(".addressdialog").html(data["message"]);
											$(".addressdialog").fadeOut(1200);
											setTimeout(function() {
												window.location.reload()
											}, 1000)
										} else {
											$(".addressdialog").show();
											$(".addressdialog").html(data["message"]);
											$(".addressdialog").fadeOut(1200);
										}
									})
								}
							}

						}
					}

				})
				$scope.page.Show = true;
			}
		})
	}
	$scope.choose_cha = function() { //取消选房按钮点击
		$scope.page.Show = false;
		$scope.page.Loginshow = false
	}
}])
app.controller("headNews", ["$scope", "$rootScope","$location", "$stateParams", "$state", "$http", function($scope, $rootScope,$location, $stateParams, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'home';
	var Id = $stateParams.Id
	var type = $stateParams.type
	$rootScope.page.goshow = true
	if(type == 1) {
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Picture/active_detail',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				Id: Id,
			}
		}).success(function(data) {
			$rootScope.page.goshow = false
			$scope.conent = data["list"]["content"]
			$scope.name = data["list"]["name"]
		})
	} else {
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Picture/headline',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				Id: Id,
			}
		}).success(function(data) {
//			console.log(data)
			$rootScope.page.goshow = false
			$scope.conent = data["list"]["content"]
			$scope.name = data["list"]["name"]
			var title = data["list"]["name"]
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'Share/share_s',
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
				data: {
					url: $location.absUrl()
				}
			}).success(function(result) {
				var appid = result.appId;
				var timestamp = result.timestamp;
				var nonceStr = result.nonceStr;
				var signature = result.signature;
				if(localStorage.getItem("user_ID")) {
					var urlAfter = $location.absUrl()+"?fff="+localStorage.getItem("user_ID")+""; 
				} else {
					var urlAfter = $location.absUrl()
				}
//				var title = "中国唯一宜居地产互联网平台"
				var imgUrl = "http://web.tl178.cn/Public/admin/slideshow/15032811371503281137.jpg"
				var desc = "天乐成立于2014年，是国内首个宜居地产互联网平台，通过自然和贴心的交互方式满足用户在热点线路上的房产投资需求，大自然是您最好的家，打开生命新维度。"
				wx.config({
					debug: false, //开启调试模式,调用的所有api的返回值会在客户端alert出来
					appId: appid, // 必填，公众号的唯一标识
					timestamp: timestamp, // 必填，生成签名的时间戳
					nonceStr: nonceStr, // 必填，生成签名的随机串
					signature: signature, // 必填，签名
					jsApiList: [
						'onMenuShareTimeline', //分享到朋友圈
						'onMenuShareAppMessage', //分享给朋友
						'onMenuShareQQ', //分享给QQ好友
						'showOptionMenu'
					]
				});

				wx.ready(function() {
					wx.showOptionMenu();
					wx.onMenuShareTimeline({
						title: title,
						desc: desc, // 分享标题							
						link: urlAfter, // 分享链接
						imgUrl: imgUrl, // 分享图片
						success: function() {
							$rootScope.shareSuccess(2)
						},
						cancel: function() {
							// 用户取消分享后执行的回调函数
						}
					});

					wx.onMenuShareAppMessage({
						title: title, // 分享标题
						desc: desc, // 分享描述
						link: urlAfter, // 分享链接
						imgUrl: imgUrl, // 分享图片
						type: '', // 分享类型,music、video或link，不填默认为link
						dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
						success: function() {
//							console.log(urlAfter)
							$rootScope.shareSuccess(1)
							// 用户确认分享后执行的回调函数
						},
						cancel: function() {
							// 用户取消分享后执行的回调函数
						}
					});

					wx.onMenuShareQQ({
						title: title, // 分享标题
						desc: desc, // 分享描述
						link: urlAfter, // 分享链接
						imgUrl: imgUrl, // 分享图标
						success: function(res) {
							$rootScope.shareSuccess(3)
							// 用户确认分享后执行的回调函数
						},
						cancel: function(res) {
							// 用户取消分享后执行的回调函数
						}
					});
				});
				wx.error(function(res) {
					console.log(res)
				});
			})
		})
	}

}])

//企业服务
app.controller("serviceList", ["$scope", "$rootScope", "$stateParams", "$state", "$http", function($scope, $rootScope, $stateParams, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'home';
	$scope.page.rongcuo = false
	$scope.type = $stateParams.id
	$rootScope.page.goshow = true
	if($stateParams.id == 1) {
		$scope.headTitle = "宜居地产"
		$scope.page.rongcuo = true
		$rootScope.page.goshow = false
	}
	if($stateParams.id == 2) {
		$scope.headTitle = "旅居生活"
		$scope.page.rongcuo = true
		$rootScope.page.goshow = false
	}
	if($stateParams.id == 4) {
		$scope.headTitle = "景区直通车"
		//		$http({
		//			method: 'post',
		//			url: '' + $rootScope.Location + 'master/master_index',
		//			headers: {
		//				'Content-Type': 'application/x-www-form-urlencoded'
		//			},
		//			data: {
		//				user_Id: localStorage.getItem("user_ID"),
		//				token: localStorage.getItem("token"),
		//			}
		//		}).success(function(data) {
		//			//			console.log(data)
		//			$scope.list = data["list"]
		//			$rootScope.page.goshow = false
		//			$scope.goInfo = function(id) {
		//				$state.go("main.serListinfo", {
		//					id: id,
		//					num: $stateParams.id
		//				})
		//			}
		//		})
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Picture/regiment',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token"),
				type: 2
			}
		}).success(function(data) {
			$rootScope.page.goshow = false
//			console.log(data)
			$scope.content = data["list"]["content"]
		})
		//		$scope.page.rongcuo = true
	}
	if($stateParams.id == 5) {
		$scope.headTitle = "合作伙伴"
		$scope.showindex = 1
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'master/partner',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token"),
			}
		}).success(function(data) {
//			console.log(data)
			$rootScope.page.goshow = false
			$scope.partner = data["list"]
		})
		$scope.clickChoose = function(index) {
			if(index == 1) {
				$scope.showindex = 1

			}
			if(index == 2) {
				$scope.showindex = 2
				$http({
					method: 'post',
					url: '' + $rootScope.Location + 'Picture/partner_way',
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						user_Id: localStorage.getItem("user_ID"),
						token: localStorage.getItem("token"),
					}
				}).success(function(data) {
//					console.log(data)
					$scope.content = data["list"]["content"]
				})
			}
		}

	}
	if($stateParams.id == 7) {
		$scope.headTitle = "幸运转盘"
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Picture/good_luck',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token")
			}
		}).success(function(data) {
			$rootScope.page.goshow = false
//			console.log(data)
			$scope.list2 = data["list"]
			$scope.goInfo = function(id) {
				window.location.href = "http://app.tl178.cn/sudoku/?id="+id
			}
		})
	}
	if($stateParams.id == 8) {
		$scope.headTitle = "我要发团"
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Picture/regiment',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token"),
				type: 1
			}
		}).success(function(data) {
			$rootScope.page.goshow = false
			if(data["list"].length <= 0) {
				$scope.page.rongcuo = true
			} else {
				$scope.content = data["list"]["content"]
				$scope.page.rongcuo = false
			}
		})
	}
	if($stateParams.id == 3) {
		$scope.headTitle = "天乐头条"
		$scope.showindex = 1
		$scope.clickChoose = function(index) {
			if(index == 1) {
				$scope.showindex = 1
			}
			if(index == 2) {
				$scope.showindex = 2
				$http({
					method: 'post',
					url: '' + $rootScope.Location + 'Picture/active',
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						user_Id: localStorage.getItem("user_ID"),
						token: localStorage.getItem("token"),
					}
				}).success(function(data) {
					$scope.list2 = data["list"]
					$scope.goInfo = function(id) {
//						console.log(id)
						$state.go("main.headLineNews", {
							Id: id,
							type: 1
						})
					}
//					console.log(data)
				})
			}
			if(index == 3) {
				$scope.showindex = 3
				$http({
					method: 'post',
					url: '' + $rootScope.Location + 'Picture/apply_aisle',
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: {
						user_Id: localStorage.getItem("user_ID"),
						token: localStorage.getItem("token"),
					}
				}).success(function(data) {
					$rootScope.page.goshow = false
					if(data["list"].length <= 0) {
						$scope.page.rongcuo = true
					} else {
						$scope.content = data["list"]["content"]
						$scope.page.rongcuo = false
					}
				})
			}
		}

		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Message/headline_list',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token"),
			}
		}).success(function(data) {
			console.log(data)
			$rootScope.page.goshow = false
			if(data["list"].length <= 0) {
				$scope.page.rongcuo = true
			} else {
				$scope.list = data["list"]
				$scope.page.rongcuo = false
				$scope.goInfo = function(id, href) {
					if(href == "") {
						$state.go("main.headLineNews", {
							Id: id
						})
					} else {
						window.location.href = href
					}
				}
			}
		})
	}
	if($stateParams.id == 6) {
		$scope.headTitle = "天乐活动"
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Message/qy_serve',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token"),
				name: $stateParams.name
			}
		}).success(function(data) {
			$rootScope.page.goshow = false
			if(data["status"] == 0) {
				$scope.page.rongcuo = true
			} else {
				if(data["list"].length <= 0) {

				} else {
					$scope.list = data["list"]
					$scope.page.rongcuo = false
				}
				$scope.goInfo = function(id) {
					$state.go("main.serListinfo", {
						id: id,
						num: $stateParams.id
					})
				}
			}
		})

	}
}])